package com.tca.spring.framework.learning.ioc.config;

import com.tca.spring.framework.learning.ioc.circulardependency.A;
import com.tca.spring.framework.learning.ioc.circulardependency.B;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.*;
import org.springframework.core.type.AnnotationMetadata;

/**
 * @author zhoua
 * @Date 2021/5/1
 */
@Configuration
@ComponentScan(value = "com.tca.spring.framework.learning.ioc.scan")
@Import(value = {ImportConfiguration.CustomImportBeanDefinitionRegistrar.class})
public class ImportConfiguration {

    static class CustomImportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {

        @Override
        public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
            registry.registerBeanDefinition("a", new RootBeanDefinition(A.class));
            registry.registerBeanDefinition("b", new RootBeanDefinition(B.class));
        }
    }
}


